import * as types from '../constants/ActionTypes';

const initialState = {
  isLogin: false,
  dealerInfo: {},
  isSuccess: false,
  errMsg: '',
  avatorStore: '', // 头像地址
  userName: '',
  perTime: '', // 从业时间
  perIntro: '', // 个人介绍
  perSex: '',
};

const EditProfileReducer = (state = initialState, action) => {
  switch (action.type) {
    case types.GET_DEALER_INFO:
      return ({ ...state,
        ...{
          dealerInfo: action.dealerInfo,
        } });
    case types.MODIFY_PERSON_MSG:
      return ({ ...state,
        ...{
          isSuccess: action.isSuccess,
          errMsg: action.errMsg,
        } });
    case types.CHANGE_AVATAR_STORE:
      return ({ ...state,
        ...{
          avatorStore: action.avatorStore,
        } });
    case types.USER_NAME:
      return ({ ...state,
        ...{
          userName: action.userName,
        } });
    case types.CHANGE_PER_STORE:
      return ({ ...state,
        ...{
          perTime: action.perTime,
        } });
    case types.CHANGE_PER_STORE_INTRO:
      return ({ ...state,
        ...{
          perIntro: action.perIntro,
        } });
    case types.CHANGE_PER_STORE_SEX:
      return ({ ...state,
        ...{
          perSex: action.perSex,
        } });
    default:
      return state;
  }
};

export default EditProfileReducer;
